package com.eastmelon.tcp;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;


/**
 * @author Administrator
 * problem:文件中没有数据
 */
public class UploadServer1 {
	public static void main(String[] args) throws Exception {
		ServerSocket ss=new ServerSocket(10004);
		Socket s=ss.accept();
		String ip=s.getLocalAddress().getHostAddress();
		System.out.println(ip+".....connected");
		BufferedReader bufIn=new BufferedReader(new InputStreamReader(s.getInputStream()));
		PrintWriter out=new PrintWriter(new FileWriter("D:\\server.txt",true));
		String line=null;
		while((line=bufIn.readLine())!=null){
			out.println(line);
		}
		PrintWriter pw=new PrintWriter(s.getOutputStream(),true);
		pw.println("上传成功");
		out.close();
		s.close();
		ss.close();
	}

}
